<extend name="Layout:layout_content" />
<block name="body_main">
    <div class="grid-parent xsui-page-header">
        <div class="grid-60 mobile-grid-100 grid-parent">
            <a href="{:U('customer_edit')}" class="xsui-btn ui-state-default lnk-add"><i class="fa fa-plus"></i>新增</a>
            <a href="{:U('customer_export')}" class="xsui-btn ui-state-default"><i class="fa fa-save"></i>导出</a>
            <a href="{:U('customer_recycle','id=varkey')}" class="xsui-btn ui-state-default lnk-remove" data-options="confirm_message:'您确定要把{n}个客户移到回收站吗?'"><i class="fa fa-trash"></i>批量回收站</a>
            <if condition="equal_permission('KH_KHGL_DDKH')">
                <a href="{:U('CustomerDispatch/dispatch_edit','customer_id=varkey')}" class="xsui-btn ui-state-default lnk-edit-dialog"><i class="fa fa-edit"></i>批量调度</a>
            </if>
        </div>
        <div class="grid-40 mobile-grid-100 grid-parent xsui-text-right">
            <a href="#" class="xsui-btn ui-state-default lnk-refresh"><i class="fa fa-refresh"></i>刷新</a>
            <span class="xsui-input-group">
                <form method="get">
                    <input type="text" name="search_key" value="{$search.search_key}" placeholder="工号/编号/姓名/手机号码" />
                    <button type="submit" class="ui-state-default"><i class="fa fa-search"></i>搜索</button><button id="btn-search-dialog" class="ui-state-default xsui-icon-only" title="高级搜索"><i class="fa fa-gear"></i></button>
                </form>
            </span>
        </div>
        <div id="search-dialog" class="xsui-hidden" style="width:340px;">
            <form method="get" class="xsui-form">
                <table>
                    <foreach name="searchlist" item="vo">
                        <tr><th>{$vo.title}</th><td><sohtml:select name="operate_{$vo.field_name}" items="EQ:等于;LIKE:模糊匹配;GT:大于;LT:小于;NEQ:不等于" value="EQ" /></td><td><input type="text" name="{$vo.field_name}" placeholder="{$vo.title}" class="{$vo.class}" /></td></tr>
                    </foreach>
                </table>
                <button type="submit">保存</button>
            </form>
        </div>
    </div>
    <if condition="$show_aside">
    <table width="100%">
        <tr>
            <td valign="top" style="background-color:#dce9f9; font-weight: bold;">
                <ul class="xsui-tree" data-active-value="{$search['departmentid']}">
                    <foreach name="departments" item="vo1">
                        <li><a data-id="{$vo1.id}" href="{:U('customer_list','departmentid='.$vo1['id'])}">{$vo1.title}</a>
                        <if condition="$vo1['children']"><ul></if>
                        <foreach name="vo1['children']" item="vo2">
                            <li><a data-id="{$vo2.id}" href="{:U('customer_list','departmentid='.$vo2['id'])}">{$vo2.title}</a>
                            <if condition="$vo2['children']"><ul></if>
                            <foreach name="vo2['children']" item="vo3">
                                <li><a data-id="{$vo3.id}" href="{:U('customer_list','departmentid='.$vo3['id'])}">{$vo3.title}</a></li>
                            </foreach>
                            <if condition="$vo2['children']"></ul></if>
                            </li>
                        </foreach>
                        <if condition="$vo1['children']"></ul></if>
                        </li>
                    </foreach>
                </ul>
            </td>
            <td valign="top"><div id="grid-container">{$content}</div></td>
        </tr>
    </table>
        <else/>
        <div id="grid-container">{$content}</div>
    </if>
    <input type="hidden" id="customer-edit-dialog-url" value="{:U('Customer/customer_edit','tel=vartel')}" />
    <input type="hidden" id="dialout-url" value="/xcall/index.php/XCall/CtiManager/seat_dialout_save/phone/vartel/exten/{$login_data['user_name']}" />
</block>
<block name="body_after">
    <script type="text/javascript">
        // 选中节点 2016-8-5 SoChishun Added.
        var $tree = $('.xsui-tree');
        if ($tree.data('activeValue')) {
            $tree.find('a[data-id="' + $tree.data('activeValue') + '"]').addClass('active');
        }
        $tree.parent().width($tree.width() < 85 ? 85 : $tree.width());
        // 发起呼叫 2016-3-25
        $('.lnk-dialout').click(function () {
            window.parent.exten_dialout($(this).attr('href'));
            return false;
            /*
             if(window.parent.check_exten_status()){
             alert('分机未签入!');
             }
             var tel = $(this).attr('href');
             // 先弹屏
             var url = $('#customer-edit-dialog-url').val();
             ifrmDialog.open_edit_dialog(url.replace('vartel', tel), {title: '来电弹屏 ' + tel}, 'screen_popup_man{n}', 'screen_popup_man', 3);
             // 再呼叫
             url = $('#dialout-url').val();
             $.get(url.replace('vartel', tel), function (data) {
             console.log(data);
             if (data.status) {
             
             } else {
             alert(data.info);
             }
             })
             return false;
             */
        })
    </script>
</block>